package main.test;

import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

public class TTTEST {

    public static void main(String[] args) {
        User user1 = new User("1","chensm");
        User user2 = new User("1","chensm222");
        User user3 = new User("2","chensm222");

        List<User> list = Arrays.asList(user1,user2,user3);



       /* List list2 = Arrays.asList(1,2,3,4,5,6,7,8,9,10,11);

        int size = list2.size() ;

        int count = size / 3 + (size % 3 > 0 ? 1 : 0);

        for (int i = 0; i < count; i++) {
            if(i != count - 1){
                List list1 = list2.subList(i * 3, (i + 1) * 3);
                System.out.println(list1);

            }
            
            else{
                List list1 = list2.subList(i * 3, size);
                System.out.println(list1);
            }
        }*/


//        list = list.stream() .collect(
//                Collectors.collectingAndThen(Collectors.toCollection(() ->
//                        new TreeSet<>(Comparator.comparing(user ->        user.getId()))), ArrayList::new));


        Map<String, User> collect = list.stream().collect(Collectors.toMap(m -> m.getId().toString(), Function.identity()));

        System.out.println(12);
    }

    static public class User {
        String id;

        String name;

        public User(String id, String name) {
            this.id = id;
            this.name = name;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }
}
